package MediaOnline.General;

import android.content.Context;
import android.net.ConnectivityManager;

public class checkNetwork {
	
	public boolean checkConn(Context ctx)
    {
		ConnectivityManager connMgr = (ConnectivityManager)
		ctx.getSystemService(Context.CONNECTIVITY_SERVICE);

		final android.net.NetworkInfo wifi =  connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		final android.net.NetworkInfo mobile =  connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

		if( wifi.isAvailable() || mobile.isAvailable() ){
			return true;
		}
		else
		{
			return false;
		}
    }
	
	
	public boolean UseMobileConnection (Context ctx){
		ConnectivityManager connMgr = (ConnectivityManager)
		ctx.getSystemService(Context.CONNECTIVITY_SERVICE);

		final android.net.NetworkInfo wifi =  connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		final android.net.NetworkInfo mobile =  connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

		if( mobile.isAvailable()){
			return true;  	//true là kết nối bằng 3g, gprs...
		}
		else {
			return false;	//false là sử dụng kết nối nhanh như wifi hay mạng dây
		}
				
	}
	
	
	
}
